package com.black.carbon.mapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.black.carbon.entity.displaySet;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.Map;

@Repository
public interface DisplayMapper extends BaseMapper<displaySet> {
    @Select("select p.create_time, p.update_time, p.id, p.title, p.top, p.content, p.admin, p.reader, p.cid, p.descr, p.status, c.name from posts p, catalog c where p.cid = c.cid and p.cid = #{cid} and p.status = 1 and c.status = 1 order by ${orderBy} desc")
    Page<Map<String, Object>> postsListPage(Page<Map<String, Object>> page, @Param(Constants.WRAPPER) Wrapper<displaySet> wrapper, Integer cid, String orderBy);

    @Select("select * from displayset where title = #{title}")
    displaySet selectByTitle(String title);

    @Insert("insert into displayset(title,img,content,tag) values(#{title},#{img},#{content},#{tag})")
    void save(displaySet displayset);
}
